// SelectDswDlg.cpp : implementation file
/*********************************************************************
*	Author         : orbit
*	Date           : July 6, 2003
* Last-modified  : April 19, 2004 
*	Contact us     : inte2000@163.com,support@winmsg.com
*	Web Page       : http://www.winmsg.com/cn/orbit.htm (for Chinese version)
*						       http://www.winmsg.com/orbit.htm (for English version)
**********************************************************************/

#include "stdafx.h"
#include "tabbars.h"
#include "SelectDswDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CSelectDswDlg dialog


//##ModelId=431C34C902FD
CSelectDswDlg::CSelectDswDlg(CStringArray& aFiles, CWnd* pParent /*=NULL*/)	: CDialog(CSelectDswDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSelectDswDlg)
	m_strSelectFile = lpszNull;
	//}}AFX_DATA_INIT
	m_aFiles.Copy(aFiles);
}


//##ModelId=431C34C9032C
void CSelectDswDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSelectDswDlg)
	DDX_Control(pDX, IDC_LIST_DSWFILE, m_lstDswFiles);
	DDX_LBString(pDX, IDC_LIST_DSWFILE, m_strSelectFile);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSelectDswDlg, CDialog)
	//{{AFX_MSG_MAP(CSelectDswDlg)
	ON_LBN_SELCHANGE(IDC_LIST_DSWFILE, OnSelchangeFilelist)
	ON_LBN_DBLCLK(IDC_LIST_DSWFILE, OnDblclkFilelist)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSelectDswDlg message handlers
//##ModelId=431C34C9033D
void CSelectDswDlg::OnSelchangeFilelist() 
{
	UpdateData();

	GetDlgItem(IDOK)->EnableWindow(m_lstDswFiles.GetCurSel() != LB_ERR);
}

//##ModelId=431C34C9034B
BOOL CSelectDswDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// fill list
	int nFile = m_aFiles.GetSize();

	if (!nFile)
		EndDialog(-1);
	else
	{
		while (nFile--)
			m_lstDswFiles.AddString(m_aFiles[nFile]);

		m_lstDswFiles.SetSel(0);
	}
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

//##ModelId=431C34C9035B
void CSelectDswDlg::OnDblclkFilelist() 
{
	UpdateData();

	if (m_lstDswFiles.GetCurSel() != LB_ERR)
		EndDialog(IDOK);
}
